package com.cn.lyl.servlet;

import com.cn.lyl.dao.LawyerDao;

import com.cn.lyl.model.LawyerModel;
import com.cn.lyl.service.LawyersService;
import com.cn.lyl.util.LawyerFileOperation;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

@WebServlet("/lawyers")
public class LawyersServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        LawyerDao lawyerDao = new LawyerDao();
        LawyerFileOperation lawyerFileOperation = new LawyerFileOperation();
        LawyersService lawyersService = new LawyersService();

        String path = req.getServletContext().getRealPath("");
        List <LawyerModel> lawyers=lawyersService.getLawyersList(path);

        req.setAttribute("lawyers",lawyers);
        req.getRequestDispatcher("/jsp/lawyers.jsp").forward(req,resp);
    }
}
